<template>
  <page-wrap stay-still back title="普工职位" hide-tab>
    <view class="unskilled-job">
      <job-list
        class="uj-list"
        v-if="postList.length"
        :data="postList"
        :props="postProp"
        :status="moreLoading"
        @item-click="handleJobItem"
      ></job-list>
      <u-empty text="暂无数据" v-else></u-empty>
    </view>
  </page-wrap>
</template>

<script>
import JobList from "@/components/JobList";
import { searchZp } from "@/api/index";
export default {
  components: { JobList },
  data() {
    return {
      postList: [],
      postProp: {
        title: "jtzw",
        salary: "xzdy_new",
        cname: "cname_all",
        time: "updatetime",
        region: "regionname",
      },
      pageParam: {
        page: 0,
        pageSize: 20,
      },
      moreLoading: "loadmore",
      shareTitle: this.$selfName + " - 普工职位",
      sharePath: '/pagesSub/index/unskilledJob/index',
    };
  },
  onReachBottom() {
    this.$set(this.pageParam, "page", this.pageParam.page + 1);
    this.handleJobList();
  },
  // onShareAppMessage() {
  //   return {
  //     title: this.$selfName + " - 普工职位",
  //     path: "/pagesSub/index/unskilledJob/index",
  //   };
  // },
  // onShareTimeline() {
  //   return {
  //     title: this.$selfName + " - 普工职位",
  //     path: "/pagesSub/index/unskilledJob/index",
  //   };
  // },
  mounted() {
    this.handleJobList();
  },
  methods: {
    handleJobList() {
      if (this.moreLoading == "loading" || this.moreLoading == "nomore") return;
      this.moreLoading = "loading";
      // let param = {
      //   tradeid: this.$tradeId,
      //   regionid: "0",
      //   conditionArr: JSON.stringify({
      //     jobtypes: "实习",
      //     page: this.pageParam.page,
      //     page_size: this.pageParam.pageSize,
      //   }),
      // };
      // getHotJob(param).then((res) => {
      //   this.moreLoading = "nomore";
      //   this.postList.push(...res.data);
      // });
      let param = {
        tradeid: this.$tradeId,
        queryItemArr: JSON.stringify({
          jtzw: "普工",
        }),
        conditionArr: JSON.stringify({
          page: this.pageParam.page,
          page_size: this.pageParam.pageSize,
        }),
      };
      searchZp(param).then((res) => {
        this.postList.push(...res.data);
        this.moreLoading = "loadmore";
        if (this.pageParam.page >= res.pageparam.pages) {
          this.moreLoading = "nomore";
        }
      });
    },
    handleJobItem(item) {
      uni.navigateTo({
        url: "/pagesSub/public/jobDetail/index?jobId=" + item.id,
      });
    },
  },
};
</script>

<style lang="scss">
.unskilled-job {
  ::v-deep .job-list {
    padding: 32rpx;
  }
  ::v-deep .u-empty {
    position: absolute;
    left: 50%;
    top: 48%;
    transform: translate(-50%, -50%);
  }
}
</style>

